﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.SANY.Util;

namespace PMS.SANY.Entity
{
    /// <summary>
    /// 数据字典
    /// </summary>
    public partial class CF_Enum : BusEntity
    {
        /// <summary>
        /// 公司Id
        /// </summary>
        public string CompanyId { get; set; }
        /// <summary>
        /// 编号
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 系统必须
        /// </summary>
        public bool IsSystem { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
    }

    public partial class CF_Enum : BusEntity
    {
        /// <summary>
        /// 仓库
        /// </summary>
        //public Bas_Whse Whse { get; set; }
        public List<CF_EnumItem> EnumItems { get; set; }
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class CF_EnumTypeConfig : BusEntityTypeConfig<CF_Enum>, IEntityTypeConfiguration<CF_Enum>
    {
        public override void Configure(EntityTypeBuilder<CF_Enum> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            //builder.HasOne(o => o.Whse).WithMany().HasForeignKey(p => p.WhseId).OnDelete(DeleteBehavior.ClientCascade);
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.Code).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.Name).HasMaxLength(EntityDefinition.DefMiddleColLen).IsRequired();
            builder.Property(p => p.IsSystem).HasDefaultValue(false);
            builder.Property(p => p.Remark).HasMaxLength(EntityDefinition.DefMiddleColLen);
            #endregion

            #region 备注
            builder.HasComment("数据字典");
            builder.Property(p => p.Code).HasComment("编号");
            builder.Property(p => p.Name).HasComment("名称");
            builder.Property(p => p.IsSystem).HasComment("系统必须");
            builder.Property(p => p.Remark).HasComment("备注");
            #endregion

            #region 种子数据
            #region Define
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_StationType", CompanyId = EntityDefinition.DefSysCode, Code = "StationType", Name = "工位类型", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });

            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_EleCarType", CompanyId = EntityDefinition.DefSysCode, Code = "EleCarType", Name = "车型编码", IsSystem = true, Remark = "车型电气编码", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_EleMi_9000", CompanyId = EntityDefinition.DefSysCode, Code = "EleMi_9000", Name = "封头编码", IsSystem = true, Remark = "电气编码", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_EleMi_91001", CompanyId = EntityDefinition.DefSysCode, Code = "EleMi_91001", Name = "前锥拼板编码", IsSystem = true, Remark = "电气编码", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_EleMi_92001", CompanyId = EntityDefinition.DefSysCode, Code = "EleMi_92001", Name = "圆柱拼板编码", IsSystem = true, Remark = "电气编码", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_EleMi_93001", CompanyId = EntityDefinition.DefSysCode, Code = "EleMi_93001", Name = "后锥前拼板编码", IsSystem = true, Remark = "电气编码", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_EleMi_94001", CompanyId = EntityDefinition.DefSysCode, Code = "EleMi_94001", Name = "后锥拼板编码", IsSystem = true, Remark = "电气编码", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_EleMi_9100", CompanyId = EntityDefinition.DefSysCode, Code = "EleMi_9100", Name = "前锥筒体编码", IsSystem = true, Remark = "电气编码", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_EleMi_9200", CompanyId = EntityDefinition.DefSysCode, Code = "EleMi_9200", Name = "圆柱筒体编码", IsSystem = true, Remark = "电气编码", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_EleMi_9300", CompanyId = EntityDefinition.DefSysCode, Code = "EleMi_9300", Name = "后锥前筒体编码", IsSystem = true, Remark = "电气编码", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_EleMi_9400", CompanyId = EntityDefinition.DefSysCode, Code = "EleMi_9400", Name = "后锥筒体编码", IsSystem = true, Remark = "电气编码", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_EleMi_9600", CompanyId = EntityDefinition.DefSysCode, Code = "EleMi_9600", Name = "叶片编码", IsSystem = true, Remark = "电气编码", CreateUserId = "1", ModifyUserId = "1" });
            #endregion
            #region Exec
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_AgvTaskType", CompanyId = EntityDefinition.DefSysCode, Code = "AgvTaskType", Name = "AGV任务类型", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_AgvTaskStatus", CompanyId = EntityDefinition.DefSysCode, Code = "AgvTaskStatus", Name = "AGV任务状态", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });
            #endregion
            #region Sys,CF
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_Sex", CompanyId = EntityDefinition.DefSysCode, Code = "Sex", Name = "性别", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_YesOrNo", CompanyId = EntityDefinition.DefSysCode, Code = "YesOrNo", Name = "是否", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_CF_Config_Type", CompanyId = EntityDefinition.DefSysCode, Code = "CF_Config_Type", Name = "配置类型", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_CF_CodeRule_Type", CompanyId = EntityDefinition.DefSysCode, Code = "CF_CodeRule_Type", Name = "规则类型", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_State", CompanyId = EntityDefinition.DefSysCode, Code = "State", Name = "启用状态", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });
            
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_Unit", CompanyId = EntityDefinition.DefSysCode, Code = "Unit", Name = "单位", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_UnitLevel", CompanyId = EntityDefinition.DefSysCode, Code = "UnitLevel", Name = "单位级别", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_Rotation", CompanyId = EntityDefinition.DefSysCode, Code = "Rotation", Name = "优先规则", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CF_Enum() { Id = $"{EntityDefinition.DefSysCode}_SyncStatus", CompanyId = EntityDefinition.DefSysCode, Code = "SyncStatus", Name = "同步状态", IsSystem = true, Remark = "", CreateUserId = "1", ModifyUserId = "1" });

            #endregion

            #endregion
        }
    }
}
